home *** CD-ROM | disk | FTP | other *** search
/ distrib.akp.su/Programming/Vb-6+Rus/ / distrib.akp.su.tar / distrib.akp.su / Programming / Vb-6+Rus / ! BIBLIOTEKI ! / SENDFORM.2_0 / vb_source.z / sendform2.bas next >
BASIC Source File  |  1997-12-08  |  5KB  |  102 lines

  1. Attribute VB_Name = "Module2"
  2. '----------------------------------------------------------------------
  3. '
  4. '       vb_sendform.bas
  5. '
  6. '
  7. ' VERSION: 1.0  (July 16, 1997)
  8. '
  9. '
  10. '----------------------------------------------------------------------
  11. '
  12. '               Usage Main Rutin
  13. '
  14. '
  15. '               In Data (When system run your program, all data already in these variables)
  16. '
  17. '                       Global VB_BRIDGE_RequestMethod As String    "POST", "GET",
  18. '                               "DBOK", "DBFAILED", "SEARCHRESULT", "DATANUMBER", "KEYNUMBER", or "NONE"
  19. '                       Global VB_BRIDGE_LocalIP As String          Local IP Address Who accessed
  20. '                       Global VB_BRIDGE_ServerAdmin As String      On Error, System return Error message
  21. '                                                       which send this E-mail address to user
  22. '                       Global VB_BRIDGE_ConnectionHandle As Integer    Unless user closes this session,
  23. '                                                           this number never changes.
  24. '
  25. '
  26. '               Functions and sub-rutin
  27. '                       Function SetServerAdminiEmail(szAdminiEmail As String)
  28. '                                       This function set Administrator's E-Mail Address to system.
  29. '                                       Once, you have to do this in the program.
  30. '                       Function GetField(key As String) As String
  31. '                                       This function get the field data which mutch with specified key.
  32. '                       Function GetCheckBoxField(Key As String, n As Integer) As String
  33. '                                       This function get the check box field data which mutch with specified key and location.
  34. '                       Sub Send(sData As String)
  35. '                                       This sub-rutin send string to the server.
  36. '                       Function SendFile(szFile As String)
  37. '                                       This function reads a specified file and send string to the server
  38. '
  39. '               Start with Sub Program_Main()
  40. '                       Return Value (Set to VB_BRIDGE_ReturnType)
  41. '                               =1: Sent HTML document to server
  42. '                               =2: Sent URL to server
  43. '                               =4: Sent Image Binary File (Gif, Jpeg) to server
  44. '
  45. '----------------------------------------------------------------------
  46. Private Declare Function VB_SendForm Lib "vb_sendform2.dll" (ByVal szLogPath As String, ByVal SMTP As String, ByVal SMRPPort As Long, ByVal szTo As String, ByVal szCC As String, ByVal szName As String, ByVal szFrom As String, ByVal szSubject As String, ByVal szDescription As String, ByVal szAttach As String, ByVal bDeleteAttachFileAfterSend As Long) As Long
  47. Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  48.  
  49. Global g_sLogPath As String
  50. Global g_sSMTP As String
  51. Global g_nSMTPPort As Long
  52. Global g_sTo As String
  53. Global g_sCC As String
  54. Global g_sName As String
  55. Global g_sFrom As String
  56. Global g_sSubject As String
  57. Global g_sDescription As String
  58. Global g_sAttach As String
  59.  
  60.  
  61. Sub Program_Main()
  62. '       ReturnToISAPI() Value
  63. '       =1: Sent HTML or IMAGE document to server and cut connection
  64. '       =2: Sent URL to jump and cut connection
  65.     Dim nRet As Long
  66.     Dim szIni As String
  67.     Dim bDeleteAttachFileAfterSend As Long
  68.  
  69.     SetServerAdminiEmail ("your_addministrator_email")   ' Set Addministrator E-Mail Address for error occurred
  70.  
  71.     Select Case VB_BRIDGE_RequestMethod
  72.         Case "POST":
  73.             g_sLogPath = GetField("LOGPATH")
  74.             szIni = g_sLogPath + "\vb_sendform.ini"
  75.             g_sSMTP = String$(201, " ")
  76.             nRet = GetPrivateProfileString("SMTP", "Server", "", g_sSMTP, 200, szIni)
  77.             g_sSMTP = Left$(g_sSMTP, InStr(g_sSMTP, Chr$(0)) - 1)
  78.             g_nSMTPPort = 25
  79.             g_sTo = GetField("TO")
  80.             g_sCC = GetField("CC")
  81.             g_sName = GetField("NAME")
  82.             g_sFrom = GetField("FROM")
  83.             g_sSubject = GetField("SUBJECT")
  84.             g_sDescription = GetField("DESCRIPTION")
  85.             g_sAttach = GetField("ATTACH")
  86.             bDeleteAttachFileAfterSend = 0    '=0: don't delete attached file after sent mail, =1: delete attached file after sent
  87.             nRet = VB_SendForm(g_sLogPath, g_sSMTP, g_nSMTPPort, g_sTo, g_sCC, g_sName, g_sFrom, g_sSubject, g_sDescription, g_sAttach, bDeleteAttachFileAfterSend)
  88.             If nRet = 1 Then
  89.                 Send ("Content-Type: text/html" + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10))
  90.                 SendFile (g_sLogPath + "\ok.htm")
  91.             Else
  92.                 Send ("Content-Type: text/html" + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10))
  93.                 SendFile (g_sLogPath + "\failed.htm")
  94.             End If
  95.             ReturnToISAPI (1)
  96.         Case Else
  97.             Send ("Content-Type: text/html" + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10))
  98.             SendFile (g_sLogPath + "\failed.htm")
  99.             ReturnToISAPI (1)
  100.     End Select
  101. End Sub
  102.